package com.dgut.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class webConfig implements WebMvcConfigurer {
    @Autowired
    private HandlerInterceptor loginInterceptor;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/user/**").addResourceLocations("file:D:/user/upload");
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/","/login","/css/**","/images/**","/iCode","/error","/downloadFile","/register.html","/register")
//        .excludePathPatterns("/*")
//        .excludePathPatterns("/upload")
//        .excludePathPatterns("/fileUpload")
//        .excludePathPatterns("/user/**")
        ;
    }
}
